package org.rency.common.trigger.util;

public class TriggerDict {

	/** 未知主机信息 */
    public static final String  UNKNOW_HOST                = "UNKNOW_HOST";
    
    /** 后台任务触发监听器名称 */
    public static final String  DAEMON_TRIGGER_LISTENER    = "daemonTriggerListener";
    
    public static final String  DAEMON_SCHEDULER_NAME = "DaemonScheduler";
    
    public static final String  DAEMON_GROUP_NAME = "DaemonGroup";
    
    public static final String  DAEMON_TRIGGER_NAME = "DaemonTrigger_";
    
    public static final String JOB_DETAIL_SUFFIX = "JobDetail";
    public static final String JOB_BEAN_SUFFIX = "Job";
    public static final String JOB_EXECUTE_METHOD = "execute";
    public static final String JOB_TRIGGER_ID = "triggerId";
    
    /** 真标记 */
    public static final String  TRUE_STRING                = "Y";
    /** 假标记 */
    public static final String  FALSE_STRING               = "N";
    
    public static final String SQL_TABLE_NAME = "tc_daemon_task_trigger";
    
    public static final String SQL_CREATE_TABLE = "create table "+SQL_TABLE_NAME+" (trigger_id int auto_increment primary key,bean_name varchar(200) not null,description varchar(255) not null,cron_expression varchar(50),previous_fire datetime,next_fire datetime,status varchar(50) not null,concurrent_enable varchar(2) not null,machine_ip varchar(50),machine_host varchar(200),memo varchar(255),update_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,create_time timestamp not null default '0000-00-00 00:00:00')ENGINE=InnoDB DEFAULT CHARSET=utf8";
    public static final String SQL_CREATE_UNIQUE_INDEX = "create unique index idx_bean_name on "+SQL_TABLE_NAME+" (bean_name)";
    
    public static final String SQL_LOAD_ALL = "select * from "+SQL_TABLE_NAME;
    public static final String SQL_FIND_BY_ID = "select * from "+SQL_TABLE_NAME+" where trigger_id = ?";
    public static final String SQL_FIND_BY_NAME = "select * from "+SQL_TABLE_NAME+" where bean_name = ?";
    public static final String SQL_LOAD_BY_STATUS = "select * from "+SQL_TABLE_NAME+" where status = ?";
    public static final String SQL_LOAD_BY_MACHINE = "select * from "+SQL_TABLE_NAME+" where machine_ip = ?";
    
    public static final String SQL_INSERT = "insert into "+SQL_TABLE_NAME+"(bean_name,description,cron_expression,previous_fire,next_fire,status,concurrent_enable,machine_ip,machine_host,memo,create_time) values(?,?,?,?,?,?,?,?,?,?,?)";
    
    public static final String SQL_UPDATE_CRON = "update "+SQL_TABLE_NAME+" set cron_expression = ? where bean_name = ?";
    public static final String SQL_UPDATE_NEXT_FIRE = "update "+SQL_TABLE_NAME+" set next_fire = ? where trigger_id = ?";
    public static final String SQL_UPDATE_PREVIOUS_FIRE = "update "+SQL_TABLE_NAME+" set previous_fire = ? where trigger_id = ?";
    public static final String SQL_UPDATE_FIRE = "update "+SQL_TABLE_NAME+" set previous_fire = ?,next_fire = ? where trigger_id = ?";
    public static final String SQL_UPDATE_STATUS_BULK = "update "+SQL_TABLE_NAME+" set status = ? where status = ?";
    public static final String SQL_UPDATE_STATUS_BY_ID = "update "+SQL_TABLE_NAME+" set status = ? where trigger_id = ? and status = ?";
    public static final String SQL_UPDATE_STATUS_BY_NAME = "update "+SQL_TABLE_NAME+" set status = ? where bean_name = ? and status = ?";
    public static final String SQL_UPDATE_MACHINE = "update "+SQL_TABLE_NAME+" set machine_ip = ?,machine_host = ? where trigger_id = ?";
    public static final String SQL_UPDATE_STATUS_MACHINE_FIRE_BY_ID = "update "+SQL_TABLE_NAME+" set status = ?,machine_ip = ?,machine_host = ?,previous_fire = ?,next_fire = ? where trigger_id = ? and status = ?";
    public static final String SQL_UPDATE_STATUS_MACHINE_FIRE_BY_NAME = "update "+SQL_TABLE_NAME+" set status = ?,machine_ip = ?,machine_host = ?,previous_fire = ?,next_fire = ? where bean_name = ? and status = ?";
    
    public static final String SQL_DELETE_BY_ID = "delete from "+SQL_TABLE_NAME+" where trigger_id = ?";
    public static final String SQL_DELETE_BY_BEAN_NAME = "delete from "+SQL_TABLE_NAME+" where bean_name = ?";
	
}